<?php
$redir=urldecode($_GET['redir']);
if(!$_SESSION['group_id']){redir("./");exit;}
?>
<div class="box">
  <h2>กรุณาเลือกสาขาวิชา</h2>
  <div class="boxContent">
    <p>
		<?php
		$sql="select * from department order by dep_id";
		$res=mysql_query($sql);
		echo "<ul>";
		while($dep=mysql_fetch_assoc($res)){
			echo "<li>$dep[dep_name]<ul>";
			$sql="select * from branch where dep_id='$dep[dep_id]' order by branch_id";
			$res2=mysql_query($sql);
			while($branch=mysql_fetch_assoc($res2)){
				echo "<li><a href=$redir&branch_id=$branch[branch_id]>$branch[branch_name]</a></li>";
			}
			echo "</ul></li>";
		}
		echo "</ul>";
		?>
    </p>
  </div>
</div>